package com.education.welco.controller;

import com.education.utils.BaiduAipContentCensor;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: liftsail
 * @Date: 2022/11/9 17:24
 * @Description: 不积跬步无以至千里
 */
@RestController
@RequestMapping("/aip")
public class TestController {

    @Autowired
    private BaiduAipContentCensor baiduAipContentCensor;

    /**
     * 上传完成以后拿到url路径进行接口调用
     *
     * 1.图片的处理逻辑
     *
     * 2.文本的处理逻辑
     * 直接调用接口进行审核并且返回审核结果
     * 3.视频的处理逻辑
     * 异步处理  或者在新增资源的时候进行审核
     */

    /**
     * {"conclusion":"合规","log_id":16680438334293545,"isHitMd5":false,"conclusionType":1}
     * conclusionType 1：合规，2：不合规，3：疑似，4：审核失败
     */
    /**
     * @return
     */

    @GetMapping("/image")
    public String image() {
        JSONObject jsonObject = baiduAipContentCensor.AipImage("1595899770924.jpg");
        String s = jsonObject.toString();
        return s;
    }

    @GetMapping("/batchImage")
    public String batchImage(String url) {
        JSONObject jsonObject = baiduAipContentCensor.AipImage(url);
        return jsonObject.toString();
    }

    @GetMapping("/text")
    public String test02() {
        int i = baiduAipContentCensor.AipText("你是个小垃圾");
        return i + "";
    }

    @GetMapping("/video")
    public String test03() {
        boolean b = baiduAipContentCensor.AipVideo2("1202211091056181057539684.mp4");
        return b + "";
    }

}
